package cn.blunce.Map;

import java.util.Arrays;
import java.util.HashMap;

/**
 * Created by Experiment on 2016/6/22 0022.
 */
public class Expmt_Hashtable {
    public static void main(String[] args) {
        HashMap<MyKey, Integer> dic = new HashMap<MyKey, Integer>();
        dic.put(new MyKey(1, 2, 3, 4), 3);
        dic.put(new MyKey(1, 2, 3, 5), 19);
        System.out.println(dic.get(new MyKey(1, 2, 3, 4)));
        System.out.println(dic.get(new MyKey(1, 2, 3, 5)));

//        System.out.println(new int[]{1, 2, 3} == new int[]{1, 2, 3});
    }


}

class MyKey {
    public int[] value;

    public MyKey(int i, int j, int wide, int height) {
        value = new int[]{i, j, wide, height};
    }

    @Override
    public boolean equals(Object obj) {
        return Arrays.equals(this.value, ((MyKey) obj).value);
    }

    @Override
    public int hashCode() {
        return Arrays.hashCode(this.value);
    }
}
